package com.dove.task;

import com.alibaba.fastjson.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;


@Component
public class DefAsyncRedisNoticeTask implements MessageListener {

	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Override
	public void onMessage(Message message, byte[] pattern) {
		String body = new String(message.getBody());
		String channel = new String(message.getChannel());

		if ("redis.channel.test".equals(channel)) {
			logger.info("redis.channel.test=" + channel + ", " + body);
			
			JSONObject jsonObj = JSONObject.parseObject(body);
			String out_trade_no = jsonObj.get("out_trade_no").toString();
			System.out.println(out_trade_no);
		}else {
			logger.info("none" + channel + ", " + body);
		}
	}
}